package com.houxiurong.dao;

import com.houxiurong.entity.BlogType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 博客类型操作的Dao
 *
 * @author houxiurong
 */
public interface BlogTypeDao extends JpaRepository<BlogType, Integer> {

    //获取博客类别信息
    @Query("SELECT t2.*, COUNT(t1.id) AS blogTypeCount" +
            " FROM Blog t1 JOIN BlogType t2" +
            " ON t1.type_id = t2.id" +
            " GROUP BY t2.type_name" +
            " ORDER BY t2.order_num")
    List<BlogType> getBlogTypeData();

}
